package com.booking.dao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.booking.dao.entity.RoomInfo;
import com.booking.dao.mapper.RoomInfoMapper;
import com.booking.dao.service.RoomInfoService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Qikai.Lin
 * @date 2023/4/23
 */
@Service
public class RoomInfoServiceImpl extends ServiceImpl<RoomInfoMapper, RoomInfo> implements RoomInfoService {
    @Override
    public List<RoomInfo> getListByHomestayId(Long homestayId) {
        QueryWrapper<RoomInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("homestay_id", homestayId);
        return this.baseMapper.selectList(queryWrapper);
    }

    @Override
    public RoomInfo getByName(String name) {
        QueryWrapper<RoomInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("name", name);
        return this.getOne(queryWrapper);
    }
}
